home *** CD-ROM | disk | FTP | other *** search
File List | 1988-11-11 | 16.5 KB | 748 lines |
- ' *****************************************************************************
- ' * KILLER CHESS ST - A translation of the Atari 8-bit Action! version *
- ' * By Greg "Crazed Iguana" Knauss *
- ' * Copyright 1988 Antic Publishing *
- ' *****************************************************************************
- '
- ' Set up two screens for page flipping
- '
- Gosub Allocate_screens
- '
- ' *****************************************************************************
- ' Make sure the computer's in low resolution
- ' *****************************************************************************
- '
- '
- Orig_res%=Xbios(4)
- If Orig_res%=2 Then
- Alert 1,"|Killer Chess can only|run on a color monitor...|",1,"Shucks!",X
- End
- Endif
- '
- If (Not Exist("killscrn")) Or (Not Exist("killsets"))
- Alert 1,"KILLSCRN and KILLSETS must|be in the same directory|as KILLER.PRG",1,"Abort",D
- End
- Endif
- '
- ' Switch to low resolution (This, unfortunatly, does funny things to the COLOR
- ' command, so both player's cursors come up grey if they start the game from
- ' medium resolution.)
- '
- Void Xbios(5,L:Physbase%,L:Logbase%,0)
- '
- ' *****************************************************************************
- ' Do dem DIMs (And other assorted start-up stuff)
- ' *****************************************************************************
- '
- Hidem
- Dim Spalette%(16,3)
- @Save_pal
- For I=0 To 15
- Setcolor I,1911
- Next I
- '
- Dim Piece$(6,1,1,2)
- Dim Set(1)
- Dim X(1)
- Dim Y(1)
- Dim Ox(1)
- Dim Oy(1)
- Dim Bord(7,7)
- Dim Hold(1)
- Dim Pau(1)
- Dim Nte(1)
- Dim Oct(1)
- Dim Joy(1)
- Nte(0)=6
- Oct(0)=4
- Nte(1)=6
- Oct(1)=4
- '
- ' *****************************************************************************
- ' The Holy Grail of STdom, the joystick init routine! Woo!
- ' (I don't understand how it works, I don't care how it works... I just care
- ' THAT it works. Of course, the point is now moot, since GFA 3.0 has it's
- ' own joystick routines... Sigh.)
- ' *****************************************************************************
- '
- Mc$=Mki$(&H23C8)+Mkl$(*A%)+Mki$(&H4E75)
- V%=Xbios(34)+24
- O%=Lpeek(V%)
- Lpoke V%,Varptr(Mc$)
- A%=0
- Out 4,&H16
- Repeat
- Until A%
- Lpoke V%,O%
- Joy(0)=A%+1
- Joy(1)=A%+2
- Out 4,&H14
- '
- ' *****************************************************************************
- ' Get pieces out of KILLSETS file
- ' *****************************************************************************
- '
- Get 0,0,159,119,Screen$
- Bload "KILLSETS",Varptr(Screen$)
- Put 0,0,Screen$
- For K=0 To 2
- For Plr=0 To 1
- For I=0 To 1
- For J=0 To 5
- Get I*20+Plr*40+K*80,J*20,I*20+19+Plr*40+K*80,J*20+19,Piece$(J+1,Plr,I,K)
- Next J
- Next I
- Next Plr
- Next K
- '
- ' *****************************************************************************
- ' Set up screen
- ' *****************************************************************************
- '
- Cls
- '
- ' Set screen colors
- '
- Setcolor 0,7,7,7 ! Background
- Setcolor 1,6,0,0 ! Red squares
- Setcolor 2,0,0,0 ! Black squares
- Setcolor 3,4,4,4 ! Border
- Setcolor 4,4,4,7 ! Player one cursor
- Setcolor 5,0,0,7 ! Player two cursor
- Setcolor 6,2,5,3 ! Dragon color one
- Setcolor 7,2,6,3 ! Dragon color two
- '
- ' Get screen from KILLSCRN
- '
- Sget Screen$
- Bload "KILLSCRN",Varptr(Screen$)
- Sput Screen$
- Gosub Copy_screen(1,2)
- '
- ' ******************************************************************************
- ' Board set ups and pieces colors
- ' ******************************************************************************
- '
- Set_data:
- '
- ' Set 1
- '
- Data 2,1,0,0,0,0,7,8
- Data 3,1,0,0,0,0,7,9
- Data 4,1,0,0,0,0,7,10
- Data 5,1,0,0,0,0,7,11
- Data 6,1,0,0,0,0,7,12
- Data 4,1,0,0,0,0,7,10
- Data 3,1,0,0,0,0,7,9
- Data 2,1,0,0,0,0,7,8
- '
- ' Set 2
- '
- Data 2,0,0,7,1,0,0,8
- Data 3,0,0,7,1,0,0,9
- Data 4,0,0,7,1,0,0,10
- Data 5,0,0,7,1,0,0,11
- Data 6,0,0,7,1,0,0,12
- Data 4,0,0,7,1,0,0,10
- Data 3,0,0,7,1,0,0,9
- Data 2,0,0,7,1,0,0,8
- '
- ' Set 3
- '
- Data 0,0,0,0,0,0,0,0
- Data 1,1,0,0,0,0,7,7
- Data 4,3,1,0,0,7,9,10
- Data 5,2,1,0,0,7,8,11
- Data 6,2,1,0,0,7,8,12
- Data 4,3,1,0,0,7,9,10
- Data 1,1,0,0,0,0,7,7
- Data 0,0,0,0,0,0,0,0
- '
- ' Set 4
- '
- Data 5,1,1,0,0,7,7,12
- Data 1,1,0,0,0,0,7,7
- Data 1,0,3,0,0,9,0,7
- Data 0,0,0,0,0,0,0,0
- Data 0,0,0,0,0,0,0,0
- Data 1,0,9,0,0,3,0,7
- Data 1,1,0,0,0,0,7,7
- Data 6,1,1,0,0,7,7,11
- '
- Piece_colors_1:
- '
- Data 1092,1365,1638,1911
- Data 1365,1328,1891,1814
- '
- Piece_colors_2:
- '
- Data 546,819,1092,1365
- Data 1092,1891,832,1347
- '
- ' *****************************************************************************
- ' Squares
- ' *****************************************************************************
- '
- Get 126,6,145,25,Red$
- Get 152,6,171,25,Blk$
- '
- ' *****************************************************************************
- ' Game options
- ' *****************************************************************************
- '
- Start:
- '
- Screen_set_ups:
- Restore Set_data
- For K=0 To Screen
- For I=0 To 7
- For J=0 To 7
- Read Bord(J,I)
- Next J
- Next I
- Next K
- '
- Prnt_pieces:
- '
- ' Put up the blank board
- '
- Sput Screen$
- '
- ' Copy it to second screen
- '
- Gosub Copy_screen(1,2)
- '
- ' Set colors
- '
- Restore Piece_colors_1
- For L=0 To Set(0)
- For I=8 To 11
- Read J
- Setcolor I,J
- Next I
- Next L
- '
- Restore Piece_colors_2
- For L=0 To Set(1)
- For I=12 To 15
- Read J
- Setcolor I,J
- Next I
- Next L
- '
- ' Put pieces on board
- '
- Gosub Set_screen
- For I=0 To 7
- For J=0 To 7
- If Bord(J,I)<>0 Then
- Put J*24+126,I*24+6,Piece$(Bord(J,I)+6*(Bord(J,I)>6),-(Bord(J,I)>6),-((I+J)/2=Int((I+J)/2)),Set(-(Bord(J,I)>6)))
- Endif
- Next J
- Next I
- Gosub Add_screen
- Deftext 3,0,0,4
- Text 15,150,"<SPACE> TO START"
- Text 23,157,"<ESC> TO EXIT"
- '
- Repeat
- '
- ' Game options
- '
- I=Inp(2)
- '
- ' Different board set ups
- '
- If I=27 Then
- Gosub Finished
- Endif
- '
- If I=187 Then
- Screen=Screen+1
- If Screen=4 Then
- Screen=0
- Endif
- Goto Screen_set_ups
- Endif
- '
- ' Different pieces
- '
- J=0
- Repeat
- If I=188+J Then
- Set(J)=Set(J)+1
- If Set(J)=2 Then
- Set(J)=0
- Endif
- Goto Prnt_pieces
- Endif
- J=J+1
- Until J=2
- '
- Until I=32
- '
- ' *****************************************************************************
- ' Inits
- ' *****************************************************************************
- '
- Plr=0
- X(0)=0
- Y(0)=3
- X(1)=7
- Y(1)=3
- Hold(0)=0
- Hold(1)=0
- Pau(0)=0
- Pau(1)=0
- '
- ' *****************************************************************************
- ' And they're off!
- ' *****************************************************************************
- '
- ' Game loop
- '
- Deftext 3,0,0,4
- Text 15,150," "
- Text 23,157," "
- Interupted!=False
- Do
- '
- ' Set up all the stuff for page-flipping
- '
- Gosub Set_screen
- Text 30,152,"<SPACE> TO"
- Text 35,159,"QUIT GAME"
- '
- B=Peek(Joy(Plr))
- '
- Interupted!=(Asc(Inkey$)=32)
- Exit If Interupted!
- '
- ' They're moving
- '
- If B And 15 Then
- '
- ' Do da movement
- '
- X1=0
- Y1=0
- If B And 1 And Y(Plr)>0 Then
- Y1=-1
- Endif
- If B And 2 And Y(Plr)<7 Then
- Y1=1
- Endif
- If B And 4 And X(Plr)>0 Then
- X1=-1
- Endif
- If B And 8 And X(Plr)<7 Then
- X1=1
- Endif
- '
- ' Erase old cursor and move
- '
- If X1<>0 Or Y1<>0 Then
- Gosub Erase
- X(Plr)=X(Plr)+X1
- Y(Plr)=Y(Plr)+Y1
- Endif
- Endif
- '
- ' Redraw cursor
- '
- Color 4+Plr*3
- Box X(Plr)*24+124,Y(Plr)*24+4,X(Plr)*24+124+23,Y(Plr)*24+27
- Box X(Plr)*24+125,Y(Plr)*24+5,X(Plr)*24+124+22,Y(Plr)*24+26
- '
- ' ***********************************************************************
- ' Did they pick up/put down a piece?
- ' ***********************************************************************
- '
- If B>127 And Pau(Plr)=0 Then
- '
- ' Pick up
- '
- If Hold(Plr)=0 Then
- If Bord(X(Plr),Y(Plr))>=Plr*6+1 And Bord(X(Plr),Y(Plr))<=Plr*6+6 Then
- Hold(Plr)=Bord(X(Plr),Y(Plr))
- Ox(Plr)=X(Plr)
- Oy(Plr)=Y(Plr)
- Put 4+91*Plr,176,Piece$((Bord(X(Plr),Y(Plr))-Plr*6),Plr,0,Set(-(Bord(X(Plr),Y(Plr))>6)))
- Pau(Plr)=5
- Endif
- Else
- Pau(Plr)=5
- '
- ' Set it down
- '
- ' Are they on top of something?
- '
- Cap=0
- If Bord(X(Plr),Y(Plr))>0 Then
- Cap=1
- Endif
- '
- ' *********************************************************************
- ' Check for legal move!
- ' *********************************************************************
- '
- Ok=0
- '
- ' Get delta values
- '
- Dx=X(Plr)-Ox(Plr)
- Dy=Y(Plr)-Oy(Plr)
- '
- ' Flip for black player
- '
- If Plr=1 Then
- Dx=-Dx
- Dy=-Dy
- Endif
- '
- ' Pawn
- '
- If Hold(Plr)=1+Plr*6 Then
- If Dx=1 And Dy=0 And Cap=0 Then
- Ok=1
- Endif
- If Dx=2 And Dy=0 And Cap=0 And Ox(Plr)=1+5*Plr And Screen=0 Then
- Ok=1
- Endif
- If Dx=1 And (Dy=1 Or Dy=-1) And Cap=1 Then
- Ok=1
- Endif
- Endif
- '
- ' Rook
- '
- If Hold(Plr)=2+Plr*6 Then
- If (Dx<>0 And Dy=0) Or (Dx=0 And Dy<>0) Then
- Ok=1
- Endif
- Endif
- '
- ' Knight
- '
- If Hold(Plr)=3+Plr*6 Then
- If (Dx=2 And Dy=1) Or (Dx=-2 And Dy=1) Then
- Ok=1
- Endif
- If (Dx=2 And Dy=-1) Or (Dx=-2 And Dy=-1) Then
- Ok=1
- Endif
- If (Dx=1 And Dy=2) Or (Dx=-1 And Dy=2) Then
- Ok=1
- Endif
- If (Dx=1 And Dy=-2) Or (Dx=-1 And Dy=-2) Then
- Ok=1
- Endif
- Endif
- '
- ' Bishop
- '
- If Hold(Plr)=4+Plr*6 Then
- If Dx=Dy Or Dx=-Dy Then
- Ok=1
- Endif
- Endif
- '
- ' King
- '
- If Hold(Plr)=5+Plr*6 Then
- If (Dx=1 And Dy=1) Or (Dx=0 And Dy=1) Or (Dx=-1 And Dy=1) Then
- Ok=1
- Endif
- If (Dx=1 And Dy=0) Or (Dx=0 And Dy=0) Or (Dx=-1 And Dy=0) Then
- Ok=1
- Endif
- If (Dx=1 And Dy=-1) Or (Dx=0 And Dy=-1) Or (Dx=-1 And Dy=-1) Then
- Ok=1
- Endif
- Endif
- '
- ' Queen
- '
- If Hold(Plr)=6+Plr*6 Then
- If Dx=Dy Or Dx=-Dy Then
- Ok=1
- Endif
- If (Dx<>0 And Dy=0) Or (Dx=0 And Dy<>0) Then
- Ok=1
- Endif
- Endif
- '
- ' They tried to capture one of their own pieces... Duh.
- '
- If Bord(X(Plr),Y(Plr))>=Plr*6+1 And Bord(X(Plr),Y(Plr))<=Plr*6+6 Then
- Ok=0
- Endif
- '
- ' They didn't move...
- '
- If Dx=0 And Dy=0 Then
- Ok=1
- Endif
- '
- ' Make sure they didn't jump pieces except with knight
- '
- If Hold(Plr)<>3+6*Plr Then
- I=Ox(Plr)
- J=Oy(Plr)
- X1=0
- Y1=0
- If Dx<0 Then
- X1=-1
- Else
- If Dx>0 Then
- X1=1
- Endif
- Endif
- If Dy<0 Then
- Y1=-1
- Else
- If Dy>0 Then
- Y1=1
- Endif
- Endif
- If Plr=1 Then
- X1=-X1
- Y1=-Y1
- Endif
- If Dx<-1 Or Dx>1 Or Dy<-1 Or Dy>1 Then
- Repeat
- I=I+X1
- J=J+Y1
- If Bord(I,J)<>0 Then
- Ok=0
- Endif
- Until (I=X(Plr)-X1 And J=Y(Plr)-Y1) Or I=0 Or I=7 Or J=0 Or J=7
- Endif
- Endif
- '
- ' Legal move!
- '
- If Ok=1 Then
- '
- ' Queen me!
- '
- If Hold(Plr)=1+6*Plr And X(Plr)=7-7*Plr Then
- Hold(Plr)=6+6*Plr
- Endif
- '
- ' Kill other players HOLD if that's what was caught
- '
- If X(Plr)=Ox(1-Plr) And Y(Plr)=Oy(1-Plr) Then
- Hold(1-Plr)=0
- Put 4+91*(1-Plr),176,Blk$
- Endif
- '
- ' Erase old piece and draw new one
- '
- A$=Blk$
- If (Ox(Plr)+Oy(Plr))/2=Int((Ox(Plr)+Oy(Plr))/2) Then
- A$=Red$
- Endif
- Put Ox(Plr)*24+126,Oy(Plr)*24+6,A$
- Put X(Plr)*24+126,Y(Plr)*24+6,Piece$(Hold(Plr)-6*Plr,Plr,-((X(Plr)+Y(Plr))/2=Int((X(Plr)+Y(Plr))/2)),Set(Plr))
- '
- ' Was the captured piece the other guy's king?
- '
- If Bord(X(Plr),Y(Plr))=11-Plr*6 Then
- Bord(X(Plr),Y(Plr))=Hold(Plr)
- Goto Finis
- Endif
- '
- ' Make change in memory
- '
- Bord(Ox(Plr),Oy(Plr))=0
- Bord(X(Plr),Y(Plr))=Hold(Plr)
- '
- ' Erase HOLD
- '
- Hold(Plr)=0
- Deffill 0
- Put 4+91*Plr,176,Blk$
- '
- Nte(Plr)=6
- Oct(Plr)=4
- Else
- '
- ' Illegal move...
- '
- Nte(Plr)=2
- Oct(Plr)=1
- Endif
- Endif
- Endif
- '
- ' Decrease pause value
- '
- If Pau(Plr)>0 Then
- Sound Plr,Pau(Plr)*3,Nte(Plr),Oct(Plr)
- Pau(Plr)=Pau(Plr)-1
- Else
- Sound Plr,0,0,0
- Endif
- '
- ' On to the next player
- '
- Plr=1-Plr
- '
- ' Flip to what we've been drawing, so the animation looks quick
- '
- Gosub Add_screen
- '
- Loop
- '
- ' *****************************************************************************
- ' Game over
- ' *****************************************************************************
- '
- Finis:
- '
- ' Erase the HOLDs and cursors
- '
- Put 4+91*Plr,176,Blk$
- Gosub Erase
- Plr=1-Plr
- Put 4+91*Plr,176,Blk$
- Gosub Erase
- '
- If Not Interupted!
- ' Clear all the losers pieces off the board
- '
- For I=0 To 7
- For J=0 To 7
- If Bord(J,I)>Plr*6 And Bord(J,I)<(Plr*6)+7 Then
- A$=Blk$
- If (I+J)/2=Int((I+J)/2) Then
- A$=Red$
- Endif
- Put J*24+126,I*24+6,A$
- Endif
- Next J
- Next I
- '
- ' Flip!
- '
- Gosub Add_screen
- '
- ' Yawn...
- '
- Pause 250
- '
- Else
- Pause 50
- Gosub Add_screen
- Endif
- '
- Goto Start
- '
- Procedure Finished
- Out 4,8
- @Restorepal
- Void Xbios(5,L:Physbase%,L:Logbase%,Orig_res%)
- End
- Return
- '
- ' *****************************************************************************
- ' Routine to erase PLRs cursor
- ' *****************************************************************************
- '
- Procedure Erase
- Color 3
- If (X(Plr)+Y(Plr))/2=Int((X(Plr)+Y(Plr))/2) Then
- Color 2
- Endif
- Box X(Plr)*24+124,Y(Plr)*24+4,X(Plr)*24+124+23,Y(Plr)*24+27
- Box X(Plr)*24+125,Y(Plr)*24+5,X(Plr)*24+124+22,Y(Plr)*24+26
- Return
- '
- ' *****************************************************************************
- ' Heaping shovelfuls of thanks to Helvetica Bold for teaching my all about
- ' page-flipping on the ST. He wouldn't let me form a religion around him,
- ' however.
- ' *****************************************************************************
- '
- ' Do the initial set ups
- '
- Procedure Allocate_screens
- '
- ' Save original screen settings:
- '
- Physbase%=Xbios(2)
- Logbase%=Xbios(3)
- '
- Dim Screen$(2),Screen%(2)
- '
- ' Set up two screens in memory. More are just as easy. Each needs to be
- ' on a 512 byte boundry, so dimension a string to 32512 bytes and then
- ' move to the boundry.
- '
- Screen%(1)=Physbase%
- Screen$(2)=Space$(32512)
- Screen%(2)=(Int(Varptr(Screen$(2))/512)+1)*512
- '
- ' Copy screen one to screen two.
- '
- @Copy_screen(1,2)
- Return
- '
- ' Set up for page-flip
- '
- Procedure Set_screen
- Vsync
- Void Xbios(5,L:Screen%(2),L:Screen%(1),-1)
- Return
- '
- ' Do the flip
- '
- Procedure Add_screen
- Void Xbios(5,L:Screen%(1),L:Screen%(2),-1)
- Gosub Copy_screen(2,1)
- Void Xbios(5,L:Screen%(1),L:Screen%(1),-1)
- Return
- '
- ' Generic copy screen
- '
- Procedure Copy_screen(Source%,Dest%)
- Vsync
- Bmove Screen%(Source%),Screen%(Dest%),32000
- Return
- '
- ' ------------- SAVE ORIGINAL COLOR PALETTE -----------------------
- Procedure Save_pal
- '
- ' Requires Dim Spalette%(16,3)
- '
- For Z%=0 To 15
- Dpoke Contrl,26
- Dpoke Contrl+2,0
- Dpoke Contrl+6,2
- Dpoke Intin,Z%
- Dpoke Intin+2,0
- Vdisys
- Spalette%(Z%,0)=Dpeek(Intout+2)
- Spalette%(Z%,1)=Dpeek(Intout+4)
- Spalette%(Z%,2)=Dpeek(Intout+6)
- Next Z%
- Return
- '
- Procedure Restorepal
- ' --------------------- RESTORES PALLET -------------------
- ' Dimensions: Spalette%(16,3)
- '
- For Z%=0 To 15
- Dpoke Contrl,14
- Dpoke Contrl+2,0
- Dpoke Contrl+6,4
- Dpoke Intin,Z%
- Dpoke Intin+2,Spalette%(Z%,0)
- Dpoke Intin+4,Spalette%(Z%,1)
- Dpoke Intin+6,Spalette%(Z%,2)
- Vdisys
- Next Z%
- Return
- '
-